package dale.web.english.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import seo.dale.util.database.LikeSearchUtils;
import dale.web.common.model.Condition;
import dale.web.common.model.PagedList;
import dale.web.common.page.Pager;
import dale.web.english.model.English;
import dale.web.english.repository.EnglishRepository;

@Service
public class EnglishServiceImpl implements EnglishService {
	
	@Autowired
	private EnglishRepository repository;

	@Override
	public English detail(Integer no) {
		return repository.selectOne(no);
	}

	@Override
	public PagedList<English> search(Condition<English> condition) {
		int rowTotal = repository.count(condition);
		Pager pager = new Pager(condition, rowTotal);
		int offset = pager.getStartRow();
		int limit = pager.getListSize();
		List<English> list = repository.selectList(condition, offset, limit);
		
		return new PagedList<English>(pager, list);
	}

	@Override
	public void create(English item) {
		repository.insert(item);
	}

	@Override
	public void modify(English item) {
		repository.update(item);
	}

	@Override
	public void remove(Integer no) {
		repository.delete(no);
	}
	
}
